package logic

import (
	"context"
	"home-mgr/homerpc/homerpc"
	"home-mgr/homerpc/internal/svc"
	"home-mgr/model"

	"github.com/zeromicro/go-zero/core/logx"
)

type PreAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPreAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PreAddLogic {
	return &PreAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PreAddLogic) PreAdd(in *homerpc.PreAddRequest) (*homerpc.PreAddResponse, error) {
	// todo: add your logic here and delete this line

	pre := model.Pre{

		UserId:  int(in.UserId),
		HouseId: int(in.HouseId),
		Status:  "已预约",
		Time:    in.Time,
	}
	model.DB.Debug().Create(&pre)
	return &homerpc.PreAddResponse{
		PreId: int64(pre.ID),
	}, nil
}
